home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hottest 6
/
Hottest 6 (1996)(PDSoft)[!].iso
/
software
/
programming
/
c
/
cat2h
/
cat2h.doc
< prev
next >
Wrap
Text File
|
1978-11-24
|
6KB
|
178 lines
**********************************
Cat2H 1.0b
Catalog To C Header File
(c) 1992 Nico François
**********************************
Preface
=======
The programs and files in this distribution are freely distributable, but are
also copyright (c) Nico François. They may be freely distributed as long as
no more than a nominal fee is charged to cover time and copying costs.
No commercial usage is permitted without written permission from the
author. Everything in this distribution must be kept together, in original
unmodified form.
The above is generally known as freeware.
If you have suggestions or remarks about this program, or if you find
any bugs, please let me know.
Contacting the author:
Fido: 2:292/603.10 (Nico Francois)
UUCP: Nico.Francois@p10.f603.n292.z2.FidoNet.Org
Mail: Nico François
Corbielaan 13
B-3060 Bertem
BELGIUM
If you can please use e-mail. That way you'll stand a much better chance
of getting a reply quickly.
Cat2H (naturally?) requires at least Kickstart 2.0 to run.
Contents
========
1. Introduction
2. Usage
3. Example
1. Introduction
===============
Cat2H is a program I wrote because I was a bit annoyed with the way CatComp
(© Commodore) translated catalog files into C header files. CatComp will
create a header file with defines for the ids and for the strings seperately,
followed by a table which is used to find the string associated with a
particular id. Hmmm. Now that could be done more efficiently, couldn't it!?
Cat2H will translate a catalog file into a header which only holds one
define for a string (and _no_ table). Cat2H will build the string so the
first two characters will hold the string ID, followed by the actual string.
This reduces the overhead from 8 bytes (2 longs) to 2 bytes (1 word). So you
only have 25% of the overhead CatComp gices you! You also don't have the
problem of having to look up the string in a table, resulting in a speed gain
as well (especially if you have a lot of strings)!
Cat2H has only one limitation: it limits you to 65536 strings, the ID may
not be larger than that (it must fit in one word). Shouldn't pose much
problems, unless maybe you're writing an electronic dictionary :-)
2. Usage
========
Cat2H can only be used from the Shell or CLI. Use it like this:
Cat2H <catalog.cd> <header.h> [NOID]
For example: 'Cat2H reqtools.cd catalog.h'
This will translate the catalog description file 'reqtools.cd' into the C
header file 'catalog.h'.
The NOID option will cause Cat2H to leave out the string IDs. This means
you can no longer use the strings for localizing. This might be useful if you
wish to compile a version of your program that can't be localized.
Suppose you had a function 'GetString (str)' to localize a string. If you
use Cat2H with the NOID option and put '#define GetString(x) x' in your source
you will be able to compile your program in a localized and a non-localized
version.
3. Example
==========
Take for example this (small) catalog description file:
-----------------------------------------------------------------------
MSG_OUTOFMEM (1//)
Out of memory!
MSG_ABORT (//)
Abort
-----------------------------------------------------------------------
Will be translated by Cat2H to:
-----------------------------------------------------------------------
/* Header file generated by Cat2H 1.0b - DO NOT EDIT! */
#define MSG_OUTOFMEM "\x0\x1" "Out of memory!"
#define MSG_ABORT "\x0\x2" "Abort"
-----------------------------------------------------------------------
If you then include a function like this in your program:
-----------------------------------------------------------------------
char *GetStr (struct Catalog *cat, char *idstr)
{
char *local;
local = idstr + 2;
if (LocaleBase)
return ((char *)GetCatalogStr (cat, *(UWORD *)idstr, local));
return (local);
}
-----------------------------------------------------------------------
Then you can use this function like this:
-----------------------------------------------------------------------
NotifyUser (GetStr (MSG_OUTOFMEM), GetStr (MSG_ABORT));
-----------------------------------------------------------------------
If you use the function NotifyUser() a lot it is much more efficient to
have it work with IDs instead of strings (calling GetStr() from inside
NotifyUser()). This can potentionally save a _lot_ of code. Then you
can use it like this:
-----------------------------------------------------------------------
NotifyUser (MSG_OUTOFMEM, MSG_ABORT);
-----------------------------------------------------------------------
Enjoy.
PROGRAM HISTORY:
*****************************************************************************
RELEASE 1.0
First release.
*****************************************************************************
RELEASE 1.0a
Fixed small bug: Cat2H didn't work if more than two lines of text were
used for a symbol (using the '\' "continue on next line" indicator).
*****************************************************************************
RELEASE 1.0b
Fixed small bug in startup code.
Recompiled with SAS/C 6.2.
*****************************************************************************
Cat2H 1.0b written by Nico François (Yes, Nico is my first name :-)
(c) 1992 Nico François
//
Thanks to \X/ Amiga for being the best computer ever!